package com.jingxi.controller;

import com.jingxi.common.pojo.EasyUIDataGridResult;
import com.jingxi.common.pojo.JingXiResult;
import com.jingxi.model.TbItem;
import com.jingxi.service.TbItemServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ItemCotroller {
    @Autowired
    TbItemServcie tbItemServcie;
    @RequestMapping(value = "/item/{id}",method = RequestMethod.GET)
    @ResponseBody
    public TbItem getTbItemById(@PathVariable long id){
        TbItem tbItem=tbItemServcie.getTbItemById(id);
        return tbItem;
    }

//    @RequestMapping(value = "/rest/item/query/item/desc/{id}",method = RequestMethod.GET)
//    @ResponseBody
//    public TbItem getItemById(@PathVariable long id){
//        TbItem tbItem=tbItemServcie.getTbItemById(id);
//        return tbItem;
//    }

    @RequestMapping(value = "/item/save",method = RequestMethod.POST)
    @ResponseBody
    public JingXiResult saveTbItem(@Validated TbItem tbItem){
        return JingXiResult.ok(tbItemServcie.createItem(tbItem));
    }

    @RequestMapping(value = "/item/list",method = RequestMethod.GET)
    @ResponseBody
    public EasyUIDataGridResult getItemList(Integer page,Integer rows){
        EasyUIDataGridResult result=tbItemServcie.getItemList(page,rows);
        return result;
    }
//    @RequestMapping(value = "/item/list",method = RequestMethod.GET)
//    @ResponseBody
//    public EasyUIDataGridResult getItemEdit(long id){
//        EasyUIDataGridResult result=tbItemServcie.getTbItemById(id);
//        return result;
//    }



}
